﻿<%@ Page Title="" Language="C#" MasterPageFile="~/HotelPage/Hotel.master" AutoEventWireup="true" CodeFile="ChangeRoomInfo.aspx.cs" Inherits="HotelPage_ChangeRoomInfo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div style="overflow:auto;width:inherit">
    <table style="margin-left:200px;margin-right:200px;">
    <tr>
    <td>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnString %>" 
            
            SelectCommand="SELECT * FROM [RoomTable] WHERE ([hotelID] = @hotelID)" 
            ConflictDetection="CompareAllValues" 
            DeleteCommand="DELETE FROM [RoomTable] WHERE [roomID] = @original_roomID AND [hotelID] = @original_hotelID AND [roomname] = @original_roomname AND [startfreetime] = @original_startfreetime AND [endfreetime] = @original_endfreetime AND [roomsize] = @original_roomsize AND [price] = @original_price AND [freestate] = @original_freestate" 
            InsertCommand="INSERT INTO [RoomTable] ([roomID], [hotelID], [roomname], [startfreetime], [endfreetime], [roomsize], [price], [freestate]) VALUES (@roomID, @hotelID, @roomname, @startfreetime, @endfreetime, @roomsize, @price, @freestate)" 
            OldValuesParameterFormatString="original_{0}" 
            
            
            UpdateCommand="UPDATE [RoomTable] SET [roomname] = @roomname, [startfreetime] = @startfreetime, [endfreetime] = @endfreetime, [roomsize] = @roomsize, [price] = @price, [freestate] = @freestate WHERE [roomID] = @original_roomID AND [hotelID] = @original_hotelID AND [roomname] = @original_roomname AND [startfreetime] = @original_startfreetime AND [endfreetime] = @original_endfreetime AND [roomsize] = @original_roomsize AND [price] = @original_price AND [freestate] = @original_freestate">
        <DeleteParameters>
            <asp:Parameter Name="original_roomID" Type="String" />
            <asp:Parameter Name="original_hotelID" Type="String" />
            <asp:Parameter Name="original_roomname" Type="String" />
            <asp:Parameter Name="original_startfreetime" Type="DateTime" />
            <asp:Parameter Name="original_endfreetime" Type="DateTime" />
            <asp:Parameter Name="original_roomsize" Type="Int32" />
            <asp:Parameter Name="original_price" Type="Decimal" />
            <asp:Parameter Name="original_freestate" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="roomID" Type="String" />
            <asp:Parameter Name="hotelID" Type="String" />
            <asp:Parameter Name="roomname" Type="String" />
            <asp:Parameter Name="startfreetime" Type="DateTime" />
            <asp:Parameter Name="endfreetime" Type="DateTime" />
            <asp:Parameter Name="roomsize" Type="Int32" />
            <asp:Parameter Name="price" Type="Decimal" />
            <asp:Parameter Name="freestate" Type="Int32" />
        </InsertParameters>
        <SelectParameters>
            <asp:SessionParameter Name="hotelID" SessionField="hotelID" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="roomname" Type="String" />
            <asp:Parameter Name="startfreetime" Type="DateTime" />
            <asp:Parameter Name="endfreetime" Type="DateTime" />
            <asp:Parameter Name="roomsize" Type="Int32" />
            <asp:Parameter Name="price" Type="Decimal" />
            <asp:Parameter Name="freestate" Type="Int32" />
            <asp:Parameter Name="original_roomID" Type="String" />
            <asp:Parameter Name="original_hotelID" Type="String" />
            <asp:Parameter Name="original_roomname" Type="String" />
            <asp:Parameter Name="original_startfreetime" Type="DateTime" />
            <asp:Parameter Name="original_endfreetime" Type="DateTime" />
            <asp:Parameter Name="original_roomsize" Type="Int32" />
            <asp:Parameter Name="original_price" Type="Decimal" />
            <asp:Parameter Name="original_freestate" Type="Int32" />
        </UpdateParameters>
        </asp:SqlDataSource>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataSourceID="SqlDataSource1" 
            DataKeyNames="roomID,hotelID" AllowPaging="True">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="roomID" HeaderText="roomID" ReadOnly="True" 
                SortExpression="roomID" Visible="False" />
            <asp:BoundField DataField="hotelID" HeaderText="hotelID" 
                SortExpression="hotelID" ReadOnly="True" 
                Visible="False" />
            <asp:BoundField DataField="roomname" HeaderText="房间名" 
                SortExpression="roomname" />
            <asp:BoundField DataField="startfreetime" HeaderText="空闲起始时间" 
                SortExpression="startfreetime" />
            <asp:BoundField DataField="endfreetime" HeaderText="空闲结束时间" 
                SortExpression="endfreetime" />
            <asp:BoundField DataField="roomsize" HeaderText="房间类型" 
                SortExpression="roomsize" />
            <asp:BoundField DataField="price" HeaderText="价格" SortExpression="price" />
            <asp:BoundField DataField="freestate" HeaderText="房间状态" 
                SortExpression="freestate" />
        </Columns>
    </asp:GridView>
    </td>
    </tr>
    <tr>
    <td colspan="2">说明：房间类型中1为单人间、2为双人间，以此类推。房间状态0为空闲，1为占用。</td>
    </tr>
    </table>
    </div>
</asp:Content>

